//Written by Richard Lewis aka Trixmoto (c) 2007

var cNode = sNode = -1;
var tree = null;

function showtree() {
  //check for form
  if(MyForm==null) {
    alert('You must start a new project first!');
    return false;
  }
  
  //create tree
  cNode = sNode = -1;
  tree = new dTree('tree');
  tree.useCookies = false;
  tree.useStatusText = true;
  shownode(-1,MyForm);		
  document.getElementById('prop').innerHTML = tree;		
  if(sNode>-1) {
    tree.openTo(sNode,true);
    if(sNode==0) {
      tree.s(0);
    }
  }
  
  //update tabs
  view = 3;
  document.getElementById('tabs').innerHTML = addtabs();
  return showform();
}

function shownode(par,obj) {
  //create new node
  cNode++;
  var tid = cNode;
  if(obj==MyProp) {
    sNode = tid;
  }
  var lnk = "javascript:void(selectobj('"+obj.onam+"'))";
  var pic = "imgs/tre"+obj.type+".gif";
  tree.add(tid,par,obj.onam,lnk,obj.onam,'',pic,pic);
  
  //create child nodes
  if(obj.kids!=null) {
    for(var i=0;i<obj.kids.length;i++) {
      shownode(tid,obj.kids[i]);
    }
  }
}